//
//  ResidenceUnLoginView.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/10.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "ResidenceUnLoginView.h"

@interface ResidenceUnLoginView ()
///! 背景
@property (nonatomic, strong) UIImageView *bgImageView;
@property (nonatomic, strong) UILabel *titleLabel;
//! 未登录UI
@property (nonatomic, strong) UIView *unLoginView;

@end

@implementation ResidenceUnLoginView

- (UIView *)unLoginView {
  if (!_unLoginView) {
    _unLoginView = [[UIView alloc] initWithFrame:CGRectMake(0, _titleLabel.yt_bottom, ScreenWidth, _bgImageView.yt_height - _titleLabel.yt_bottom)];
    [_bgImageView addSubview:_unLoginView];
    
    UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _unLoginView.yt_width, 20)];
    tipLabel.text = YTLocalizedString(@"你仍未登入已注册之");
    tipLabel.textColor = [UIColor whiteColor];
    tipLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.0f];
    tipLabel.textAlignment = NSTextAlignmentCenter;
    [_unLoginView addSubview:tipLabel];
    
    CGFloat logoH = 13;
    if (IS_IPHONE5) {
      logoH = 10;
    }

    
    UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(tipLabel.yt_left, tipLabel.yt_bottom+10, logoH * 14, logoH)];
    logoImageView.image = [UIImage imageNamed:@"Notice_logo"];
    [_unLoginView addSubview:logoImageView];
    
    UILabel *accountLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, logoImageView.yt_top, 0, logoImageView.yt_height+1)];
    accountLabel.text = YTLocalizedString(@"账户");
    accountLabel.textColor = [UIColor whiteColor];
    accountLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.0f];
    [accountLabel sizeToFit];
    [_unLoginView addSubview:accountLabel];
    
    //
    logoImageView.yt_centerX = _unLoginView.yt_width/2 - accountLabel.yt_width/2;
    
    accountLabel.yt_left = logoImageView.yt_right + 5;
    accountLabel.yt_centerY = logoImageView.yt_centerY;
  }
  return _unLoginView;
}


- (instancetype)initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    [self createViews];
  }
  return self;
}

- (void)createViews {
  
  //!
  _bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.yt_width, self.yt_width * ITEMPRO)];
  _bgImageView.clipsToBounds = YES;
  _bgImageView.contentMode = UIViewContentModeScaleAspectFill;
  _bgImageView.image = [UIImage imageNamed:@"Oil_head_login"];
  [self addSubview:_bgImageView];
  
  //！
  _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 120, 40)];
  _titleLabel.text = YTLocalizedString(@"账户");
  _titleLabel.textColor = [UIColor whiteColor];
  _titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20.0f];
  [_bgImageView addSubview:_titleLabel];
  _titleLabel.yt_bottom = _bgImageView.yt_height/2;

  
  self.unLoginView.hidden = NO;
  
  
  
  CGFloat logoTap = 100;
  if (IS_IPHONE5) {
    logoTap = 80;
  }
  
  //!
  UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake((self.yt_width-193)/2, _bgImageView.yt_bottom+logoTap, 193, 17)];
  logoImageView.image = [UIImage imageNamed:@"Oil_logo"];
  [self addSubview:logoImageView];
  
  CGFloat fontSize = 18.0f;
  if (IS_IPHONE5) {
    fontSize = 15.0f;
  }
  
  ///!
  UILabel *remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, logoImageView.yt_bottom + 10, self.yt_width - 80, 30)];
  remindLabel.textAlignment = NSTextAlignmentCenter;
  remindLabel.textColor = DEF_GRAY;
  remindLabel.text = YTLocalizedString(@"请登入以查阅户口资讯");
  remindLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:fontSize];
  [self addSubview:remindLabel];
  
  ///! login
  _loginButton = [[UIButton alloc] initWithFrame:CGRectMake(self.yt_width/2 - 86 - 20, remindLabel.yt_bottom + 40, 86, 33)];
//  [_loginButton setImage:[UIImage imageNamed:@"Oil_Login"] forState:UIControlStateNormal];
 
  
  _loginButton.backgroundColor = DEF_RED;
  _loginButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:fontSize];
  [_loginButton setTitle:YTLocalizedString(@"登入") forState:UIControlStateNormal];
  [_loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  _loginButton.layer.masksToBounds = YES;
  _loginButton.layer.cornerRadius = 10;

  
  [self addSubview:_loginButton];
  
  
  ///
  _registButton = [[UIButton alloc] initWithFrame:CGRectMake(_loginButton.yt_right + 40, _loginButton.yt_top, _loginButton.yt_width, _loginButton.yt_height)];
//  [_registButton setImage:[UIImage imageNamed:@"Oil_regist"] forState:UIControlStateNormal];

  _registButton.backgroundColor = DEF_RED;
  _registButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:fontSize];
  [_registButton setTitle:YTLocalizedString(@"注册") forState:UIControlStateNormal];
  [_registButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  _registButton.layer.masksToBounds = YES;
  _registButton.layer.cornerRadius = 10;

  [self addSubview:_registButton];
  
  //!
  UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(_registButton.yt_left - 10, _registButton.yt_bottom + 10, _registButton.yt_width + 20, 13)];
  tipLabel.text = [NSString stringWithFormat:@"%@？",YTLocalizedString(@"还没有成为HBC会员")];
  tipLabel.textColor = HEXCOLOR(0xbb2b25);
  tipLabel.font = [UIFont systemFontOfSize:10.0f];
  tipLabel.textAlignment = NSTextAlignmentCenter;
  [self addSubview:tipLabel];
  
  //
  UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(self.yt_centerX, _loginButton.yt_top - 20, 0.8, _loginButton.yt_height + 40)];
  lineView.backgroundColor = DEF_GRAY;
  [self addSubview:lineView];

  self.yt_height = _loginButton.yt_centerY * 2 - _bgImageView.yt_height;
  
}

@end
